package cn.richard.databind.view

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import cn.richard.databind.R
import cn.richard.databind.databinding.ActivityUserBinding
import cn.richard.databind.model.UserModel
import cn.richard.databind.viewmodel.UserViewModel

class UserActivity : AppCompatActivity(), View.OnClickListener {

    private lateinit var userViewModel: UserViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val binding: ActivityUserBinding = DataBindingUtil.setContentView(this, R.layout.activity_user)

        binding.lifecycleOwner = this
        binding.userModel = UserModel()
        binding.onClick = this

        userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
        userViewModel.setUserModel(binding.userModel)
        userViewModel.getUserInfo()



    }

    override fun onClick(view: View?) {
        when(view?.id) {
            R.id.tv_select_user_info -> {

            }
        }
    }
}